<?php
namespace ctrl\demo;
use L;
use Sdk\Fop\callFopApiUtil;
use traits\StockTrait;

class fop
{
    ////http://ec.com/?c=demo_fop&a=warehouseList
    public static function warehouseList()
    {
        $method = 'com.basis.warehouse.getlist';
        $data = [
            'service_code' => 'S',
            'country' => 'US'
        ];
        $result = CallFopApiUtil::callFopApi($method, $data);
        echo '<pre />';
        print_r($result);
    }

    //拉取4px的库存数据 http://ec.com/?c=demo_fop&a=pull
    public static function pull()
    {
        $result = \serv\task\warehouse\fop::pull();
    }

    //同步库存队列  http://ec.com/?c=demo_fop&a=pullQueue
    public static function pullQueue()
    {
        $string = '{"warehouse_id":"148","warehouse_code":"AUSYDA"}';
        $data['data'] = json_decode($string, true);
        $result = \serv\queue\warehouse\fop::pull($data);
        var_dump($result);
    }

    //检查或者更新库存  http://ec.com/?c=demo_fop&a=stock
    public static function stock()
    {
        $string = '{"customer_code":"916133","sku_code":"2C030170（ECP-7815）","warehouse_code":"AUSYDA","sku_id":"921005460194","batch_no":"","stock_quality":"G","available_stock":"0","pending_stock":"0","onway_stock":"0","warehouse_id":"148"}';
        $data['data'] = json_decode($string, true);
        $skuArr = StockTrait::tran2sku($data['data']['sku_code']);
        print_r($skuArr);
        exit;
        $result = \serv\queue\warehouse\fop::check($data);
        var_dump($result);
    }

    //获取入库详情 http://ec.com/?c=demo_fop&a=inboundTask
    public static function inboundTask()
    {
        //定时任务
        //\serv\task\warehouse\inbound::inboundOrder(); exit;
        //接口详情
        $arr = '{"service":"Winit","total_qty":"8","platform_no":"WI38918803","transfer_order_id":"2"}';
        $data['data'] = json_decode($arr, true);
        \serv\queue\warehouse\InboundOrder::inbound($data);
    }
}


